package com.example.administrator.caigou51.activity;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.ab.util.AbViewUtil;
import com.example.administrator.caigou51.R;
import com.example.administrator.caigou51.control.ImageCycleViewGoods;
import com.example.administrator.caigou51.global.App;
import com.example.administrator.caigou51.recyclerCard.basic.MaterialListView;
import com.example.administrator.caigou51.recyclerCard.card.AddAgainGoodsCard;
import com.example.administrator.caigou51.util.ImageUtil;
import com.example.administrator.caigou51.widget.showPhoto.photoview.PhotoView;
import com.example.administrator.caigou51.widget.showPhoto.sample.CirclePageIndicator;
import com.example.administrator.caigou51.widget.showPhoto.sample.HackyViewPager;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/9/23/023.
 */
public class BigImageActivity  extends GBaseActivity {

    private List<String> urlList;
    public static String TagList= "TagList";
    private HackyViewPager mViewPager;
    CirclePageIndicator circlePageIndicator;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        super.setContentViewFor720_1280(R.layout.activity_big_image);
        initDatas();
    }

    private void initDatas() {
        getTopBar().setVisibility(View.GONE);
        urlList=getIntent().getStringArrayListExtra(TagList);
        mViewPager = (HackyViewPager) findViewById(R.id.view_pager);

        mViewPager.getLayoutParams().width=App.getInstance().screenWidth;
        mViewPager.getLayoutParams().height=App.getInstance().screenWidth;
        mViewPager.setTag(AbViewUtil.NotScale);

        mViewPager.setAdapter(new SamplePagerAdapter(getActivity(),urlList));
        circlePageIndicator=(CirclePageIndicator) findViewById(R.id.circlePageIndicator);
        circlePageIndicator.setFillColor(getResources().getColor(R.color.color_1ca146));
        circlePageIndicator.setViewPager(mViewPager);
    }
    public static class SamplePagerAdapter extends PagerAdapter {
        private Context context;
        private List<String> data;


        //		private static int[] sDrawables = { R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher,
//				R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher };
        public SamplePagerAdapter(Context context,List<String> data){
            this.context = context;
            this.data = data;

        }





        @Override
        public int getCount() {
            return data.size();
        }

        @Override
        public int getItemPosition(Object object) {
            // TODO Auto-generated method stub
            return POSITION_NONE;
        }

        @Override
        public View instantiateItem(ViewGroup container, final int position) {
            ImageView photoView ;

                    photoView = new PhotoView(container.getContext());



  
                    App.displayImageHttpOrFile(data.get(position), photoView, ImageUtil.OptionsNormal());


                    container.addView(photoView);
                    return photoView;
                

            
        }
        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

    }
}